package zengqiang.day05


fun main(args: Array<String>) {
    var list= listOf<String>("z","h","a")
    println(list.sorted())//[a, h, z]  正序排序
    println(list.sortedDescending()) //[z, h, a]  倒序排序

    //按照条件排序
    val list1= listOf<P1>(P1("张三年",20), P1("李四",30))
    var r1=list1.sortedBy {
        it.name
    }
    // 同理有：list1.sortedByDescending {  }
    println(r1) //[P1(name=张三年, age=20), P1(name=李四, age=30)]
}
data class P1(var name:String,var age:Int)